package club.beimeng.msmservice.email.template.entity;

import java.io.*;
import java.lang.String;
import lombok.Data;
import org.springframework.core.io.ClassPathResource;

import java.util.Arrays;

@Data
public class SendCode {
    private String title;

    private String username;

    private String code;

    private String from;

    private String content = "";

    public String getContent()  {
        try {
            InputStream inputStream = new ClassPathResource("emailTemplate/sendCode.html").getInputStream();
            byte[] bytes = new byte[1024];
            int len = 0;
            while ((len = inputStream.read(bytes))!= -1){
                content +=  new String(bytes,0,len);
            }
            inputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        content = content.replace("${username}",username).replace("${code}",code).replace("${from}",from);
        return content;
    }

    private void setContent(String content) {
        this.content = content;
    }
}
/*
 *
 * @author Mr.Bao
 * @date 2021/8/2 20:36
 */